from functools import wraps

cache_dict = {}

def cache(fn):
    @wraps(fn)
    def wrapper(*args, **kwargs):
        key = args
        for items in kwargs.items():
            key += items
        
        if key in cache_dict:
            print("hit")
            return cache_dict[key]
        ret = fn(*args, **kwargs)
        cache_dict[key] = ret
        return ret
    return wrapper

@cache
def add(x,y):
    return x+y

add(1,y=4)
print(cache_dict)